<template>
  <el-main>
    <el-card shadow="never">
      <el-tabs tab-position="top">
        <el-tab-pane label="系统设置">
          <el-form ref="form" :model="sys" label-width="100px" style="margin-top: 20px">
            <el-form-item label="验厂开关">
              <el-switch
                v-model="form.is_inspect_factory"
                :active-value="1"
                :inactive-value="0"
              ></el-switch>
              <div class="el-form-item-msg" data-v-b33b3cf8="">
                验厂开启后，所有产品名称，全称将由验厂名称替换（如果有的话）
              </div>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="submit" :disabled="disabled"
                >保存</el-button
              >
            </el-form-item>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </el-main>
</template>

<script>
export default {
  name: "system",
  data() {
    return {
      disabled: false,
      form: {
        id: 1,
        is_inspect_factory: 0,
      },
    };
  },
  mounted() {
    this.getConfig();
  },
  methods: {
    getConfig() {
      this.disabled = true;
      this.$API.system.config.getConfig
        .post(this.form)
        .then(res => {
          this.form = res.data;
        })
        .finally(() => {
          this.disabled = false;
        });
    },
    submit() {
      this.disabled = true;
      this.$API.system.config.setConfig
        .post(this.form)
        .then(res => {
          this.form = res.data;
          this.$message.success("设置成功");
        })
        .finally(() => {
          this.disabled = false;
        });
    },
  },
};
</script>

<style></style>
